package top.leyi.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
@RestController
public class ExceptionHandle {

    @ExceptionHandler({FileSizeOutofRangeException.class})
    public Map<String, String> fileSizeLimitExceededException(){
        Map<String, String> map = new HashMap<>();
        map.put("code", "400");
        map.put("msg", "文件超出大小,限制100k以下");
        return map;
    }

    @ExceptionHandler({FileTypeNotSupportException.class})
    public Map<String, String> fileTypeNotSupportException(){
        Map<String, String> map = new HashMap<>();
        map.put("code", "400");
        map.put("msg", "请使用正确的文件格式，如.png，.ipg");
        return map;
    }
}
